package day04

/**
  * [B : A] ContextBound
  */
class ContextBoundDemo [T:Ordering]{
  def select(first:T,second:T):T={
    val ord:Ordering[T] = implicitly[Ordering[T]]
    if(ord.gt(first,second)) first else second
  }
}

object ContextBoundDemo{
  def main(args: Array[String]): Unit = {
    import MyPredef.OrderingGril
    val context = new ContextBoundDemo[OrderedGirl]
    val daqiao = OrderedGirl("大乔",23,100)
    val xiaoqiao = OrderedGirl("小乔",21,100)
    val girl = context.select(daqiao,xiaoqiao)
    println(girl)
  }
}
